# Maintainer: Caleb Maclennan <caleb@alerque.com>
# Maintainer: Jelle van der Waa <jelle@vdwaa.nl>
# Contributor: Giovanni Scafora <giovanni@archlinux.org>
# Contributor: BlackEagle < ike DOT devolder AT gmail DOT com >
# Contributor: Preecha Patumchareonpol <yumyai at gmail.com> 

pkgbase=podofo
pkgname=(podofo{,-tools})
pkgver=0.10.2
pkgrel=1
pkgdesc='A C++ library to work with the PDF file format'
arch=(loong64 x86_64)
url="http://$pkgname.sourceforge.net"
_url="https://github.com/$pkgname/$pkgname"
license=(LGPL2.1)
depends=(fontconfig
         freetype2
         libidn
         libjpeg-turbo
         libpng
         libtiff
         libxml2
         lua
         openssl
         zlib)
makedepends=(cmake)
_archive="$pkgname-$pkgver"
source=("$_url/archive/$pkgver/$_archive.tar.gz")
sha256sums=('565168132e8fbfcdbad4ea4c5567bcc57ebbffb4528f6273baf3f490a3cf7563')

build() {
	cd "$_archive"
	cmake -B build \
		-D CMAKE_INSTALL_PREFIX=/usr \
		-D PODOFO_BUILD_TOOLS=True \
		-D PODOFO_HAVE_JPEG_LIB=True \
		-D PODOFO_HAVE_PNG_LIB=True \
		-D PODOFO_HAVE_TIFF_LIB=True
	make -C build
}

package_podofo() {
	provides=(libpodofo.so)
	cd "$_archive"
	make -C build DESTDIR="$pkgdir" install
	local toolspkg="$pkgdir-tools"
	mkdir -p "$toolspkg/usr/"
	mv "$pkgdir/usr/bin" $toolspkg/usr
}

package_podofo-tools() {
	license=(GPL2)
	depends+=(libpodofo.so)
	cd "$_archive"
	install -Dm0644 -t "$pkgdir/usr/share/man/man1" man/*.1
}
